package com.atom.swipebacklib;

import android.os.Parcel;
import android.os.Parcelable;
import android.support.v4.os.ParcelableCompat;
import android.support.v4.os.ParcelableCompatCreatorCallbacks;
import android.support.v4.view.AbsSavedState;

/**
 * ============================================================
 * project: MySwipBackLayout
 * package: com.atom.swipebacklib
 * fileDescribe:
 * user: admin
 * email: 1299854942@qq.com
 * createTime: 2017/7/27  12:40
 * modify:
 * version:: V1.0
 * ============================================================
 **/
public class SavedState extends AbsSavedState {

    boolean isOpen;

    protected SavedState(Parcelable superState) {
        super(superState);
    }

    protected SavedState(Parcel in, ClassLoader loader) {
        super(in, loader);
        isOpen = in.readInt() != 0;
    }


    @Override
    public void writeToParcel(Parcel dest, int flags) {
        super.writeToParcel(dest, flags);
        dest.writeByte(this.isOpen ? (byte) 1 : (byte) 0);
    }


    public static final Creator<SavedState> CREATOR = ParcelableCompat.newCreator(
            new ParcelableCompatCreatorCallbacks<SavedState>() {
                @Override
                public SavedState createFromParcel(Parcel in, ClassLoader loader) {
                    return new SavedState(in, loader);
                }

                @Override
                public SavedState[] newArray(int size) {
                    return new SavedState[size];
                }
            });
}
